﻿using AutoMapper;
using Microsoft.Data.SqlClient;
using Microsoft.Data.SqlClient.Server;
using S.EarTag.Domain.Dto;
using S.EarTag.Domain.Model;
using S.EarTag.Infrastructure.Repository.Interface.IRepository;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace S.EarTag.Infrastructure.Repository.Impl.Repository
{
    public class ProductionGradingRepository : BaseRepository<ProductionGrading>, IProductionGradingRepository
    {
        private readonly SqlSugarClient _db;
        private readonly IMapper _mapper;
        public ProductionGradingRepository(SqlSugarClient db, IMapper mapper) : base(db)
        {
            _db = db;
            _mapper = mapper;
        }
        /// <summary>
        /// 生产定级批量删除
        /// </summary>
        /// <param name="ids"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        public async Task<bool> BatchRemoveMaek(List<int> ids)
        {
            var result=await _db.Deleteable<ProductionGrading>().In(ids).ExecuteCommandAsync();
            return result > 0;
        }
        /// <summary>
        /// 根据耳号实现查询反填功能
        /// </summary>
        /// <param name="RankEarTag"></param>
        /// <returns></returns>
        public async Task<ProductionGrading> GetByIdRankEarTag(string? RankEarTag)
        {
            var result=await _db.Queryable<ProductionGrading>().Where(a=>a.RankEarTag== RankEarTag).SingleAsync();
            return result;
        }

    }
}
